/*
 * Copyright (c) 2018-2999 北京小象智慧信息科技有限公司 All rights reserved.
 *
 * https://www.xiaoxiangai.com/
 *
 * 未经允许，不可做商业用途！
 *
 * 版权所有，侵权必究！
 */

package com.yami.shop.dao;

import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yami.shop.bean.app.dto.MyOrderDto;
import com.yami.shop.bean.app.dto.OrderCountData;
import com.yami.shop.bean.app.dto.OrderStaticsDto;
import com.yami.shop.bean.distribution.UserShoppingDataDto;
import com.yami.shop.bean.dto.ShopDetailSalesDto;
import com.yami.shop.bean.model.Order;
import com.yami.shop.bean.model.OrderRefund;
import com.yami.shop.bean.param.OrderParam;
import com.yami.shop.common.util.PageAdapter;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

public interface OrderMapper extends BaseMapper<Order> {

    Order getOrderByOrderNumber(@Param("orderNumber") String orderNumber);

    List<Order> listOrderAndOrderItems(@Param("orderStatus") Integer orderStatus, @Param("lessThanUpdateTime") DateTime lessThanUpdateTime);

    List<Order> OrderAndOrderItems(@Param("refundState") Integer refundState,@Param("orderNumber") String orderNumber);

    List<Order> selectByOrderNumber(@Param("orderNumber") String orderNumber);

    void cancelOrders(@Param("order") Order order);

    void confirmOrder(@Param("orders") List<Order> orders);

    void finishOrder(@Param("orders") List<Order> orders);

    void updateByToPaySuccess(@Param("orderNumbers") List<String> orderNumbers, @Param("payType") Integer payType);

    List<Order> listOrdersDetialByOrder(@Param("order") Order order, @Param("startTime") Date startTime, @Param("endTime") Date endTime);

    List<Order> listOrdersDetialByOrderParam(@Param("adapter") PageAdapter adapter, @Param("orderParam") OrderParam orderParam);

    List<OrderRefund> listOrdersRefundByOrderParam(@Param("adapter") PageAdapter adapter, @Param("orderParam") OrderParam orderParam);

    Long countlistOrdersRefundByOrderParam(@Param("orderParam") OrderParam orderParam);

    Long  countOrderListByOrderParam(@Param("orderParam") OrderParam orderParam);

    Long countOrderDetial(@Param("orderParam") OrderParam orderParam);

    List<Long> listBoughtProdByUserIdAndShopId(@Param("shopId") Long shopId, @Param("userId") String userId);

    UserShoppingDataDto calculateUserInShopData(@Param("shopId") Long shopId, @Param("userId") String userId);

    List<MyOrderDto> listMyOrderByUserIdAndStatus(@Param("adapter") PageAdapter adapter, @Param("userId") String userId, @Param("status") Integer status);

    Long countMyOrderByUserIdAndStatus(@Param("userId") String userId, @Param("status") Integer status);

    List<MyOrderDto> listMyOrderByUserIdAndRefundState(@Param("adapter") PageAdapter adapter, @Param("userId") String userId);

    Long countMyOrderByUserIdAndRefundState(@Param("userId") String userId);

    void deleteOrders(@Param("orders") List<Order> orders);

    OrderCountData getOrderCount(String userId);

    void updatebyOrderNumber(@Param("order") Order order);

    void updateRefund(@Param("orderNumber") String orderNumber,@Param("refundState") Integer refundState,@Param("orderState") Integer orderState);

    List<OrderStaticsDto> selectTodayStatics(Long shopId);

    List<OrderStaticsDto> selectYesterdayStatics(Long shopId);

    List<OrderStaticsDto> selectPendingOrder(Long shopId);

    List<OrderStaticsDto> selectTransOrder(Long shopId);

    List<OrderStaticsDto> selectCompletedOrder(Long shopId);

    List<OrderStaticsDto> selectRefund(Long shopId);

    List<OrderStaticsDto> selectAllMember(Long shopId);

    List<OrderStaticsDto> selectAddMember(Long shopId);

    List<OrderStaticsDto> selectmonthMember(Long shopId);

    List<OrderStaticsDto> selectThisMonthStatics(Long shopId);

    List<OrderStaticsDto> selectLastMonthStatics(Long shopId);

    List<OrderStaticsDto> selectThisWeekStatics(Long shopId);

    List<OrderStaticsDto> selectLastWeekStatics(Long shopId);

    List<OrderStaticsDto> selectWeekDayMoney(Long shopId);

    List<OrderStaticsDto> selectMonthDayMoney(Long shopId);

    int getDoiSeq(Long shopId);

    List<Order> listOrderbyDvyTime(@Param("orderStatus") Integer orderStatus, @Param("lessThanUpdateTime") DateTime lessThanUpdateTime);

    List<Order> getOrderData(@Param("adapter") PageAdapter adapter,@Param("shopId")Long shopId);

    Order getOrderByPtglid(@Param("ptglid")Long ptglid);

    List<Order> getUnprocessedOrder(Long shopId);

    List<Order> getShopDetailId(@Param("adapter") PageAdapter adapter);

    int getShopDetailIdAmount(@Param("adapter") PageAdapter adapter);

    double getShopSalesVolume(Long shopId);

    List<Order> getShopDetailIdByTime(@Param("shopDetailSalesDto")ShopDetailSalesDto shopDetailSalesDto,@Param("adapter") PageAdapter adapter);

    int getShopDetailCountByTime(@Param("shopDetailSalesDto")ShopDetailSalesDto shopDetailSalesDto);

    double getShopBusinessVolumeByTime(@Param("shopDetailSalesDto")ShopDetailSalesDto shopDetailSalesDto,@Param("shopId")Long shopId);

    List<Order> listOrderNotPay(@Param("orderStatus") Integer orderStatus, @Param("lessThanUpdateTime") DateTime lessThanUpdateTime);

    List<Order> getNotPayOrder(Long cashier);
    Order getByOrderNumber(String orderNumber);

    /**
     * 支付撤销 修改订单状态
     * */
    int appOrderBackOut(@Param("orderNumber")String orderNumber,@Param("updateBy")Long updateBy);

    List<Order> getAllOrderByshopId(@Param("shopId")Long shopId,@Param("pageNumber")int pageNumber,@Param("startpageNumber")int startpageNumber);

    List<Order> getDpsOrder(@Param("shopId")Long shopId,@Param("pageNumber")int pageNumber,@Param("startpageNumber")int startpageNumber);

    List<Order> getDkdOrder(@Param("shopId")Long shopId,@Param("pageNumber")int pageNumber,@Param("startpageNumber")int startpageNumber);

    List<Order> getOrderListByEnterTime(@Param("lessThanUpdateTime") String lessThanUpdateTime);

    List<Order> getOrderListByTodayShopAState(@Param("shopId")Long shopId,@Param("startTime")Date startTime,@Param("endTime")Date endTime);

}
